﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using HalatiAlmadania.com._4idev.halatialmadania.dto;
using HalatiAlmadania.com._4idev.halatialmadania.utils;

namespace HalatiAlmadania.com._4idev.halatialmadania.dao
{
    public abstract class IDataAccessObject
    {
        private String connectionString;

        private SqlDataReader reader;

        public IDataAccessObject(String connectionString)
        {
            this.connectionString = connectionString;
        }

        protected String ConnectionString
        {
            get { return connectionString; }
        }

        protected SqlDataReader Reader
        {
            get { return reader; }
            set { reader = value; }
        }

        public abstract int create(IDataTransferObject dto);

        public abstract int update(IDataTransferObject dto);

        public abstract int delete(String key);

        public abstract IDataTransferObject get(String key);

        public abstract ICollection<IDataTransferObject> getAll(Order order);

        public abstract ICollection<IDataTransferObject> getByFilter(IDictionary<String,Object> filters, Order order);

        protected void closeReader(){
            if (!reader.IsClosed)
                reader.Close();
        }



    }
}
